package com.ruoyi.app.controller.user;

import com.ruoyi.app.business.user.UserBusiness;
import com.ruoyi.app.domain.user.update.UpdatePwd;
import com.ruoyi.common.core.web.domain.APIResult;
import com.ruoyi.service.user.model.UserInfoModel;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户信息管理
 *
 * @author Zane
 * @since 2025-09-27
 */
@RestController
@RequestMapping("/user/")
public class UserController {

  @Resource
  private UserBusiness userBusiness;

  /**
   * 用户信息
   *
   */
  @GetMapping("userInfo")
  public APIResult<UserInfoModel> getLoginUserInfo() {
    UserInfoModel userInfo = userBusiness.getLoginUserInfo();
    return APIResult.success(userInfo);
  }

  /**
   * 修改密码(原密码修改)
   *
   */
  @PostMapping("updatePwd")
  public APIResult<Void> updatePwd(@Validated @RequestBody UpdatePwd updatePwd) {
    userBusiness.updatePwd(updatePwd);
    return APIResult.success();
  }

}
